function ajax(options){
    var xhr = new XMLHttpRequest();
    var params = formdata(options.data);
    if (options.type=="GET") {
        xhr.open(options.type,options.url+'?'+params,options.isAsync);
        xhr.send();
    }
    if (options.type=="POST") {
        xhr.open(options.type,options.url,options.isAsync);
        xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xhr.send(params);
    }
    xhr.onreadystatechange = function(){
        if (xhr.readyState==4&&xhr.status==200) {
            options.success(xhr.responseText);
        }
    }
} 
function formdata(obj){
    var arr = [];
    for(var k in obj){   
        arr.push(k+'='+obj[k]);
    }
    return arr.join('&')
}